
//  MyButton.m
//  绘图板
//
//  Created by hyrMac on 15/8/5.
//  Copyright (c) 2015年 hyrMac. All rights reserved.
//

#import "MyButton.h"

@implementation MyButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        _label = [[UILabel alloc] initWithFrame:self.bounds];
        _label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_label];
    }
    return self;
}

- (void)setTitle:(NSString *)title {
    _title = title;
    _label.text = title;
}

- (void)setBlock:(Type)block {
    _block = [block copy];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    
    _block();
}

@end
